import { defineStore } from 'pinia'

interface AppState {
  theme: 'light' | 'dark'
  lang: 'zh' | 'en'
}

export const useAppStore = defineStore<'app', AppState, {}, {
  setTheme(theme: 'light' | 'dark'): void
  setLang(lang: 'zh' | 'en'): void
}>(
  'app',
  {
    state: (): AppState => ({
      theme: 'light',
      lang: 'zh'
    }),
    actions: {
      setTheme(theme: 'light' | 'dark') {
        this.theme = theme
        document.documentElement.setAttribute('data-theme', theme)
      },
      setLang(lang: 'zh' | 'en') {
        this.lang = lang
      }
    },
    persist: true
  }
) 